/*
 * @Author: liuzelin
 * @Date: 2024-04-16 21:36:33
 * @LastEditors: liuzelin
 * @LastEditTime: 2024-05-01 10:13:57
 * @Description: file content
 */
#pragma once
#include "panda-framework/panda/panda.hpp"
#include "session_param.hpp"

namespace Panda {
struct EndpointConfigure;

class PANDA_EXPORT RelayInterface {
 public:
  class Listener {
   public:
    virtual void OnConnect(RelayInterface *transport, const char *remote_ip,
                           uint16_t remote_port) = 0;
    virtual void OnDisConnect(RelayInterface *transport) = 0;
    virtual void OnSessionConnect(RelayInterface *transport,
                                  const SessionParam &param) = 0;
    virtual void OnRecv(RelayInterface *transport, uint8_t *data, size_t len,
                        uint32_t sid);
  };
  class TransmissionChannel {
   public:
    virtual void Send(uint8_t *data, size_t len);
  };

 public:
  static RelayInterface *CreateTransport(const EndpointConfigure &configure);
  virtual void Bind(const char *ip, uint16_t port) = 0;
  virtual void Connect(const char *ip, uint16_t port) = 0;
  virtual const SocketAddress &GetLocal() = 0;
  virtual const SocketAddress &GetRemote() = 0;
  virtual void Send(uint8_t *data, size_t len, const SessionParam &param) = 0;
  virtual void Close() = 0;
};
}  // namespace Panda